]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceThumbnail: Use click action
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 20 Apr 2023 01:30:04 +0000 (03:30 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 25 Apr 2023 09:01:16 +0000 (09:01 +0000)
Now that we have a convenient way of combining a draggable with
a click action, we can port the code without making it more
complicated.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2742>

js/ui/workspaceThumbnail.js

index a1e2583eafbaeb72a5636536d5ca26f7671cf28b..5ff19c9a1e4320a4fab5df8575059852703c1b67 100644 (file)
@@ -87,6 +87,11 @@ var WindowClone = GObject.registerClass({
         this._draggable.connect('drag-end', this._onDragEnd.bind(this));
         this.inDrag = false;
 
+        const clickAction = new Clutter.ClickAction();
+        clickAction.connect('clicked',
+            () => this.emit('selected', Clutter.get_current_event_time()));
+        this._draggable.addClickAction(clickAction);
+
         let iter = win => {
             let actor = win.get_compositor_private();
 
@@ -170,25 +175,6 @@ var WindowClone = GObject.registerClass({
         }
     }
 
-    vfunc_button_press_event() {
-        return Clutter.EVENT_STOP;
-    }
-
-    vfunc_button_release_event(buttonEvent) {
-        this.emit('selected', buttonEvent.time);
-
-        return Clutter.EVENT_STOP;
-    }
-
-    vfunc_touch_event(touchEvent) {
-        if (touchEvent.type != Clutter.EventType.TOUCH_END ||
-            !global.display.is_pointer_emulating_sequence(touchEvent.sequence))
-            return Clutter.EVENT_PROPAGATE;
-
-        this.emit('selected', touchEvent.time);
-        return Clutter.EVENT_STOP;
-    }
-
     _onDragBegin(_draggable, _time) {
         this.inDrag = true;
         this.emit('drag-begin');
@@ -637,6 +623,14 @@ var ThumbnailsBox = GObject.registerClass({
 
         this._thumbnails = [];
 
+        const clickAction = new Clutter.ClickAction();
+        clickAction.connect('clicked', () => {
+            this._activateThumbnailAtPoint(
+                ...clickAction.get_coords(),
+                Clutter.get_current_event_time());
+        });
+        this.add_action(clickAction);
+
         Main.overview.connectObject(
             'showing', () => this._createThumbnails(),
             'hidden', () => this._destroyThumbnails(),
@@ -721,22 +715,6 @@ var ThumbnailsBox = GObject.registerClass({
             thumbnail.activate(time);
     }
 
-    vfunc_button_release_event(buttonEvent) {
-        let { x, y } = buttonEvent;
-        this._activateThumbnailAtPoint(x, y, buttonEvent.time);
-        return Clutter.EVENT_STOP;
-    }
-
-    vfunc_touch_event(touchEvent) {
-        if (touchEvent.type == Clutter.EventType.TOUCH_END &&
-            global.display.is_pointer_emulating_sequence(touchEvent.sequence)) {
-            let { x, y } = touchEvent;
-            this._activateThumbnailAtPoint(x, y, touchEvent.time);
-        }
-
-        return Clutter.EVENT_STOP;
-    }
-
     _onDragBegin() {
         this._dragCancelled = false;
         this._dragMonitor = {